package com.ewhl.mark.meijialian;

import android.content.Context;


import com.ewhl.mark.meijialian.volley.MyErrorListener;
import com.ewhl.mark.meijialian.volley.MyReponseListener;
import com.ewhl.mark.meijialian.volley.VolleyRequest;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/9/7.
 */
public class NetValues extends VolleyRequest {

    private static NetValues netValues;

    public NetValues(Context ctx) {
        super(ctx);
    }

    public static NetValues getInstance(Context contex) {
        if (netValues == null) {
            netValues = new NetValues(contex);
        }
        return netValues;
    }

    private final static String ROOT_PATH = "http://chengjing.cnewhl.com/index.php/Api/";

    private final static String COMMON_API_URL = ROOT_PATH + "Nearstore/";
    private final static String USER_URL = ROOT_PATH + "User/";
    private final static String API_URL = ROOT_PATH + "api/";

    public void get_near_store_list(String key,String scid, String ne, String sw, double lng,  double lat,  MyReponseListener myReponseListener, MyErrorListener errorListener) {
        Map<String, Object> map = new HashMap<>();
        map.put("sw", sw);
        map.put("key", key);
        map.put("ne", ne);
        map.put("scid", scid);
        map.put("lng", lng);
        map.put("lat", lat);
        VolleyGet(COMMON_API_URL+"get_nearly_store", map, ShopBean.class,myReponseListener,errorListener);
    }
    public void get_near_store_classify( MyReponseListener myReponseListener, MyErrorListener errorListener) {

        VolleyGet(COMMON_API_URL+"get_store_class", null, StoreClassify.class,myReponseListener,errorListener);
    }
    public  void  get_shop_info(String store_id,MyReponseListener myReponseListener, MyErrorListener errorListener){
        Map<String, Object> map = new HashMap<>();
        map.put("store_id", store_id);
        VolleyGet(COMMON_API_URL+"get_store_basic_info", map, ShopInfo.class,myReponseListener,errorListener);
    }



    public void collection_store(String store_id ,String key,int is_shoucang,MyReponseListener myReponseListener, MyErrorListener errorListener){
        Map<String, String> map = new HashMap<>();
        map.put("store_id", store_id);
        map.put("key", key);
        map.put("is_shoucang", is_shoucang+"");
        VolleyPost(COMMON_API_URL+"change_shoucang", map, OptionBean.class,myReponseListener,errorListener);
    }
    /**
     * 登陆
     * @param mobile
     * @param password
     * @param callBack
     */
    public void login( String mobile,String password,  MyReponseListener callBack, MyErrorListener errorListener) {
        Map<String, Object> map = new HashMap<>();
        map.put("mobile", mobile);
        map.put("password",password);
        VolleyGet(USER_URL+"login", map, LoginBean.class,callBack,errorListener);
    }

    public void check_key(String key, MyReponseListener callBack, MyErrorListener errorListener) {
        Map<String, Object> map = new HashMap<>();
        map.put("key", key);
        VolleyGet(USER_URL+"check_key", map, OptionBean.class,callBack,errorListener);
    }

    /**
     * 三方验证登录
     * @param openid
     * @param type
     * @param callBack
     * @param errorListener
     */
    public void checkReg(String openid,String type, MyReponseListener callBack, MyErrorListener errorListener) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("openid", openid);
        map.put("type", type);
        VolleyPost(API_URL+"check_login", map, LoginBean.class, callBack,errorListener);
    }
    /**
     * 获取注册时短信验证码
     * @param mobile   scene 1 注册 2 修改密码  6 绑定手机号  3注册
     * @param callBack
     */
    public  void  send_sms(String mobile , String scene,MyReponseListener callBack, MyErrorListener errorListener) {
        Map<String, Object> map = new HashMap<>();
        map.put("mobile", mobile);
        map.put("scene", scene);
        VolleyGet(API_URL+"send_validate_code", map, OptionBean.class,callBack,errorListener);
    }

    public void user_third_reg(String nickname, String head_pic,String mobile,int sex ,String openid,String oauth,  String coed,MyReponseListener myReponseListener,MyErrorListener errorListener) {
        Map<String, String> map = new HashMap<>();
        map.put("mobile", mobile);
        map.put("head_pic", head_pic);
        map.put("nickname", nickname);
        map.put("sex", sex+"");
        map.put("code", coed);
        map.put("openid", openid);
        map.put("oauth", oauth);

        VolleyPost(API_URL+"third_reg", map, LoginBean.class,myReponseListener,errorListener);
    }

}



